package com.apes.fn.server.servicePlan.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.fn.crm.customer.FnCustomer;
import com.apes.fn.crm.customerExpand.FnCustomerExpand;
import com.apes.fn.server.servicePlan.service.ServicePlanceService;
import com.apes.fn.server.workOrder.service.MaintenanceOrderService;
import com.apes.framework.api.SpringManager;
import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.fileserver.File;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.framework.plugin.soe.metadata.BusinessAttributeValue;
import com.apes.framework.util.ApesConst;
import com.apes.framework.util.Arith;
import com.apes.framework.util.DateUtil;
import com.apes.framework.util.MapUtil;
import com.apes.scm.masterdata.car.model.CarConfiguration;
import com.apes.scm.masterdata.car.model.CarLabel;
import com.apes.scm.masterdata.car.model.CarModel;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.finance.model.CooperateType;
import com.apes.scm.masterdata.frame.model.Channel;
import com.apes.scm.masterdata.frame.model.Dept;
import com.apes.scm.masterdata.party.model.PartyRole;
import com.apes.scm.masterdata.party.repository.PartyRoleRepository;
import com.apes.scm.rbac.model.User;
import com.apes.scm.rbac.repository.UserRepository;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.*;
import java.util.stream.Collectors;



@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = TimingOffer.CONST_TABLE_NAME)
public class TimingOffer extends BaseModel {
    public static final String CONST_TABLE_NAME = "ser_timing_offer";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "获取报价数据")
    private String id;

    @Column(name = "origin", length = 32)
    @Comment("单号")
    private String origin;

    @Column(name = "business_type", length = 32)
    @Comment("单据类型")
    private String businessType;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "dept_id", referencedColumnName = "id", nullable = false)
    @Comment("门店")
    private Dept dept; // 根据服务方案定义

    @Column(name = "parts_qty", columnDefinition = "number(10) default 0")
    @Comment("配件数量")
    private int partsQty = 0;

    @Column(name = "number_of_execution", columnDefinition = "number(1,0) default 1")
    @Comment("执行次数")
    private int numberOfExecution = 0;

/*    @Column(name = "execute", columnDefinition = "number(1,0) default 0")
    @Comment("是否执行")
    private boolean execute = false;*/
}
